﻿package mvc_controller
{
	import flash.events.*;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;

	import mvc_model.Model;
	import mvc_model.NerdsPageModel;
	import mvc_view.View;

	public class NerdsController
	{
		private var _model:NerdsPageModel;
		private var _view:View;

		public function NerdsController(model:NerdsPageModel, view:View)
		{
			_model = model;
			_view = view;
		}

		// Nerd one button
		public function addNerdOneButton(button:DisplayObject)
		{
			if (button == null)
			{
				trace("null button");
			}

			button.addEventListener(MouseEvent.CLICK, goToNerdOnePage);
			button.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
			button.addEventListener(MouseEvent.ROLL_OUT, doRollOut);

			MovieClip(button).buttonMode = true;
			MovieClip(button).useHandCursor = true;
		}
		
		public function addNerdTwoButton(button:DisplayObject)
		{
			if (button == null)
			{
				trace("null button");
			}

			button.addEventListener(MouseEvent.CLICK, goToNerdTwoPage);
			button.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
			button.addEventListener(MouseEvent.ROLL_OUT, doRollOut);

			MovieClip(button).buttonMode = true;
			MovieClip(button).useHandCursor = true;
		}
		
		public function addNerdThreeButton(button:DisplayObject)
		{
			if (button == null)
			{
				trace("null button");
			}

			button.addEventListener(MouseEvent.CLICK, goToNerdThreePage);
			button.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
			button.addEventListener(MouseEvent.ROLL_OUT, doRollOut);

			MovieClip(button).buttonMode = true;
			MovieClip(button).useHandCursor = true;
		}
		
		public function addNerdFourButton(button:DisplayObject)
		{
			if (button == null)
			{
				trace("null button");
			}

			button.addEventListener(MouseEvent.CLICK, goToNerdFourPage);
			button.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
			button.addEventListener(MouseEvent.ROLL_OUT, doRollOut);

			MovieClip(button).buttonMode = true;
			MovieClip(button).useHandCursor = true;
		}
		
		public function addNerdFiveButton(button:DisplayObject)
		{
			if (button == null)
			{
				trace("null button");
			}

			button.addEventListener(MouseEvent.CLICK, goToNerdFivePage);
			button.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
			button.addEventListener(MouseEvent.ROLL_OUT, doRollOut);

			MovieClip(button).buttonMode = true;
			MovieClip(button).useHandCursor = true;
		}
		
		public function addNerdSixButton(button:DisplayObject)
		{
			if (button == null)
			{
				trace("null button");
			}

			button.addEventListener(MouseEvent.CLICK, goToNerdSixPage);
			button.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
			button.addEventListener(MouseEvent.ROLL_OUT, doRollOut);

			MovieClip(button).buttonMode = true;
			MovieClip(button).useHandCursor = true;
		}

		public function goToNerdOnePage(event:Event = null)
		{
			if (_model == null)
			{
				trace("model null");
			}

			trace("Go to nerd one page click");
		}

		public function goToNerdTwoPage(event:Event = null)
		{
			if (_model == null)
			{
				trace("model null");
			}

			trace("Go to nerd two page click");
		}
		
		public function goToNerdThreePage(event:Event = null)
		{
			if (_model == null)
			{
				trace("model null");
			}

			trace("Go to nerd three page click");
		}
		
		public function goToNerdFourPage(event:Event = null)
		{
			if (_model == null)
			{
				trace("model null");
			}

			trace("Go to nerd four page click");
		}
		
		public function goToNerdFivePage(event:Event = null)
		{
			if (_model == null)
			{
				trace("model null");
			}

			trace("Go to nerd five page click");
		}
		
		public function goToNerdSixPage(event:Event = null)
		{
			if (_model == null)
			{
				trace("model null");
			}

			trace("Go to nerd six page click");
		}

		function doRollOver(e:MouseEvent):void
		{
			e.currentTarget.scaleX = 1.05;
			e.currentTarget.scaleY = 1.05;
		}

		function doRollOut(e:MouseEvent):void
		{
			e.currentTarget.scaleX = 1;
			e.currentTarget.scaleY = 1;
		}
	}
}